package com.jhte.scheduleJob.job;

import com.jhte.scheduleJob.entity.ScheduleJob;
import com.jhte.scheduleJob.util.TaskUtils;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * @author
 * @Description: 计划任务执行处 无状态
 * @date
 */
public class QuartzJobFactory implements Job {
    public final Logger log = Logger.getLogger(this.getClass());

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        String jobJson = context.getMergedJobDataMap().getString("scheduleJob");
        JSONObject jsonObject = JSONObject.fromObject(jobJson);
        ScheduleJob scheduleJob = (ScheduleJob) JSONObject.toBean(jsonObject, ScheduleJob.class);
        //ScheduleJob scheduleJob = (ScheduleJob) context.getMergedJobDataMap().get("scheduleJob");
        TaskUtils.invokMethod(scheduleJob);
    }
}